#include "builders/baseBuilders_test.hpp"

#include "builders/opfilter/opBuilderHelperFilter.hpp"

namespace filterbuildtest
{
INSTANTIATE_TEST_SUITE_P(
    Builders,
    FilterBuilderTest,
    testing::Values(
        /*** Array Contains ***/
        FilterT({}, opfilter::opBuilderHelperContains, FAILURE()),
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeValue(R"(2)")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeValue(R"("str")"), makeValue(R"(2.2)")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"("[1,2,3,4]")")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"(null)")}, opfilter::opBuilderHelperContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"("false")"), makeValue("2")},
                opfilter::opBuilderHelperContains,
                SUCCESS()),
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperContains, SUCCESS()),
        /*** Array Not Contains ***/
        FilterT({}, opfilter::opBuilderHelperNotContains, FAILURE()),
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeValue(R"(2)")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeValue(R"("str")"), makeValue(R"(2)")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"("[1,2,3,4]")")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"(null)")}, opfilter::opBuilderHelperNotContains, SUCCESS()),
        FilterT({makeRef("ref"), makeValue(R"("false")"), makeValue("2")},
                opfilter::opBuilderHelperNotContains,
                SUCCESS()),
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperNotContains, SUCCESS())),
    testNameFormatter<FilterBuilderTest>("ArrayContains"));
} // namespace filterbuildtest

namespace filteroperatestest
{
INSTANTIATE_TEST_SUITE_P(
    Builders,
    FilterOperationTest,
    testing::Values(
        /*** Array Contains ***/
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value2")")},
                FAILURE()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContains,
                "notTarget",
                {makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": "value"})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContainsAny,
                "target",
                {makeValue(R"("value")"), makeValue(R"("value2")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperContainsAny,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")")},
                SUCCESS()),
        FilterT(R"({"target": ["value", "value2", "value3"]})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")"), makeValue(R"("value4")")},
                FAILURE()),
        FilterT(R"({"target": ["value", "value2", "value3"]})",
                opfilter::opBuilderHelperContainsAny,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")"), makeValue(R"("value4")")},
                SUCCESS()),
        FilterT(R"({"target": ["value", "value2", "value3"]})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")"), makeValue(R"("value3")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"], "ref": "value"})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeRef("ref")},
                SUCCESS()),
        FilterT(R"({"target": ["value"], "ref": "value2"})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeRef("ref")},
                FAILURE()),
        FilterT(R"({"target": ["value"], "notRef": "value"})",
                opfilter::opBuilderHelperContains,
                "target",
                {makeRef("ref")},
                FAILURE()),
        FilterT(R"({"target": ["value", "value2", "value3"], "ref": "value2"})",
                opfilter::opBuilderHelperContainsAny,
                "target",
                {makeRef("ref"), makeRef("notRef"), makeValue(R"("value")"), makeValue(R"("value4")")},
                SUCCESS()),
        /*** Array Not Contains ***/
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value2")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperNotContains,
                "notTarget",
                {makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": "value"})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value")")},
                FAILURE()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value")"), makeValue(R"("value2")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"]})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")")},
                SUCCESS()),
        FilterT(R"({"target": ["value", "value2", "value3"]})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeValue(R"("value2")"), makeValue(R"("value")"), makeValue(R"("value4")")},
                SUCCESS()),
        FilterT(R"({"target": ["value"], "ref": "value"})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeRef("ref")},
                FAILURE()),
        FilterT(R"({"target": ["value"], "ref": "value2"})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeRef("ref")},
                SUCCESS()),
        FilterT(R"({"target": ["value"], "notRef": "value"})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeRef("ref")},
                FAILURE()),
        FilterT(R"({"target": ["value", "value2", "value3"], "ref": "value2"})",
                opfilter::opBuilderHelperNotContains,
                "target",
                {makeRef("ref"), makeRef("notRef"), makeValue(R"("value")"), makeValue(R"("value4")")},
                SUCCESS())),
    testNameFormatter<FilterOperationTest>("ArrayContains"));
} // namespace filteroperatestest
